﻿@{
    ViewBag.Title = "Welcome";
}
<script src="~/Content/bootstrap.min.js"></script>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />

<style>
    .col-md-5 {
        height: 200px;
        margin-top: 20px;
    }

    .panel-heading {
        height: 40px;
    }

    .panel-body {
        height: 30px;
    }

        .panel-body a {
            font-size: 12px;
            margin-top: -23px;
        }

    .tit {
        font-size: 14px;
        margin-top: -23px;
    }

    p {
        margin-top: -7px;
        text-align: right;
        margin-right: 10px;
    }

        p a {
            font-size: 12px;
            color: #ccc;
        }
</style>

<div class="col-md-5">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5><a href="/Email/newss/1" class="tit">行业信息</a></h5>
        </div>
        <div class="panel-body">
            <a href="/Email/newsxx/">1231321</a>
        </div>
        <p><a href="#">更多>></a></p>
    </div>
</div>
<div class="col-md-5">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5><a href="/Email/newss/2" class="tit">国家政策</a></h5>
        </div>
        <div class="panel-body">
            <a href="/Email/newsxx/">1231321</a>
        </div>
        <p><a href="#">更多>></a></p>
    </div>
</div>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" style="margin-top:20px;">
    <span class="badge glyphicon glyphicon-plus" style="cursor:pointer">

    </span>发布新闻
</button>


<div class="col-md-5">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5><a href="/Email/newss/3" class="tit">社会财经</a></h5>
        </div>
        <div class="panel-body">
            <a href="/Email/newsxx/">1231321</a>
        </div>
        <p><a href="#">更多>></a></p>
    </div>
</div>

<div class="col-md-5">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5><a href="/Email/newss/4" class="tit">体育娱乐</a></h5>
        </div>
        <div class="panel-body">
            <a href="/Email/newsxx/">1231321</a>
        </div>
        <p><a href="#">更多>></a></p>
    </div>
</div>

<div class="modal fade" id="myModal" data-backdrop="false" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="myModalLable" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">发布新闻</h4>
            </div>
            <div class="modal-body">
                <table class="table">
                    <tr>
                        <td>新闻标题：<input type="text" id="txtName" /></td>
                    </tr>
                    <tr>
                        <td>新闻内容：<input type="text" id="txtContent" /></td>
                    </tr>
                    <tr>
                        <td>
                            新闻类型：
                            <select>
                                <option value="1">行业信息</option>
                                <option value="2">国家政策</option>
                                <option value="3">社会财经</option>
                                <option value="4">体育娱乐</option>
                            </select>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="add()">发布</button>
            </div>
        </div>
    </div>
</div>

<script>
    function add() {
        var name = $("#txtName").val();
        var content = $("#txtContent").val();
        var type = $("select").val();
        $.ajax({
            type: "post",
            url: "/Email/addnews",
            data: { name: name, content: content, type: type },
            success: function (result) {
                if (result > 0) {
                    alert("发布新闻成功!");
                    location.href = "/Email/Email_Index";
                    return;
                }
                alert("发布新闻失败!");
            }
        })
    }
</script>